package com.donkey.test;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.IntStream;

public class Temp {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String ori_filename = "\"阿米巴经营管理系\"\"统需求文档ABC.docx".replace("\"","");
        System.out.println(ori_filename);
        String new_filename = URLEncoder.encode(ori_filename, "UTF-8");
        System.out.println("filename=" + new_filename + ";filename*=UTF-8''" + new_filename);

        long t0 = System.nanoTime();

        //初始化一个范围100万整数流,求能被2整除的数字，toArray（）是终点方法

        int a[] = IntStream.range(0, 1_000_000).filter(p -> p % 2 == 0).toArray();

        long t1 = System.nanoTime();

        //和上面功能一样，这里是用并行流来计算

        int b[] = IntStream.range(0, 1_000_000).parallel().filter(p -> p % 2 == 0).toArray();

        long t2 = System.nanoTime();

        //我本机的结果是serial: 0.06s, parallel 0.02s，证明并行流确实比顺序流快

        System.out.printf("serial: %.2fs, parallel %.2fs%n", (t1 - t0) * 1e-9, (t2 - t1) * 1e-9);

        // 整数溢出测试
        int h = 34560;
        System.out.println("value=" + (h * 60000L));

        // Set 格式输出查看
        Set<String> areas = new HashSet<String>();
        areas.add("abc");
        areas.add("abd");
        System.out.println(String.join(",", areas));
    }
}